package com.homework2;

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;

public class Test10 {
    public static void main(String[] args) {
        HashSet<Student1> hashSet = new HashSet<>();
        Student1 s1 = new Student1("张三", 13, 11.22);
        Student1 s2 =new Student1("张三", 14, 21.22);
        Student1 s3 =new Student1("张三", 15, 31.22);
        Student1 s4 =new Student1("张三", 16, 41.22);
        Student1 s5=new Student1("张三", 17, 51.22);
        Student1 s6 = new Student1("张三", 18, 61.22);
        Collections.addAll(hashSet,s1,s2,s3,s4,s5,s6);
        Iterator<Student1> iterator = hashSet.iterator();
        double sum = 0;
        double high = iterator.next().getScore();
        double low = iterator.next().getScore();//低分
        for (Student1 student1 : hashSet) {
            sum += student1.getScore();
            if (high < student1.getScore()) {
                high = student1.getScore();
            }
            if (low > student1.getScore()) {
                low = student1.getScore();
            }
        }
        System.out.println("最高分为:"+high+","+"最低分为:"+low+","+"平均分为:"+sum/hashSet.size());
    }
}
